package com.neusoft.neuiotms.dcam.common.model;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;

import org.hibernate.annotations.LazyCollection;
import org.hibernate.annotations.LazyCollectionOption;
import org.hibernate.validator.constraints.Length;

import com.neusoft.bizcore.web.jpa.model.AbstractModel;
import com.neusoft.bizcore.web.jpa.model.Comment;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
@Entity
@Table(name = "neuiot_operation_group")
@org.hibernate.annotations.Table(appliesTo = "neuiot_operation_group", comment = "运维组表")
public class DcamOperationGroup extends AbstractModel {

    private static final long serialVersionUID = 1L;

    /** 运维组名称 */
    @NotBlank(message = "运维组名称不能为空")
    @Length(max = 255, message = "运维组名称不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '运维组名称'")
    private String name;

    /** 运维组编码 */
    @Length(max = 255, message = "运维组编码不能超过{max}位")
    @Column(length = 255, nullable = false, unique = true)
    @Comment("varchar(255) NOT NULL COMMENT '运维组编码'")
    private String code;

    /** 组长名称 */
    @NotBlank(message = "组长不能为空")
    @Length(max = 255, message = "组长不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '组长'")
    private String groupLeaderName;

    /** 组长编码 */
    @Length(max = 255, message = "组长编码不能超过{max}位")
    @Column(length = 255, nullable = false)
    @Comment("varchar(255) NOT NULL COMMENT '组长编码'")
    private String groupLeaderCode;

    /** 关联单位 */
    @ManyToMany
    @JoinTable(name = "dcom_ref_operationgroup_institutions", foreignKey = @ForeignKey(name = "none"), joinColumns = @JoinColumn(name = "operation_group_id"), inverseJoinColumns = @JoinColumn(name = "institutions_id"))
    @LazyCollection(LazyCollectionOption.FALSE)
    private List<DcamInstitutions> dcamInstitutions = new ArrayList<>();

}
